package com.suiwei.base.global;

import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

/**
 * @author suiwei
 * @date 2022-10-26 6:53
 * Spring MVC 的异常处理器
 *@ControllerAdvice与@RestControllerAdvice都可以
 *
 */
@Slf4j
@RestControllerAdvice
public class GlobalExceptionAdvice {
    //拦截所有异常信息
    @ExceptionHandler(Exception.class)
    public GlobalResponse doException(Exception ex){
        log.info("拦截所有异常",ex);
        return new GlobalResponse(false,"出现异常了！");

    }
}
